FROM jupyter/minimal-notebook:5197709e9f23
USER root

RUN echo '%users ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
RUN pip install jupyter-server-proxy httpx pcloud requests selenium

RUN apt update -qq && apt install curl dnsmasq ffmpeg file fonts-dejavu-core imagemagick firefox=75.0+build3-0ubuntu1 firefox-geckodriver=75.0+build3-0ubuntu1 openssh-server p7zip-full privoxy squid tor vim \
    php-cli php-curl php-mbstring php-json php-intl php-gd php-opcache php-pgsql php-xml postgresql -qy
RUN git clone -q https://git.tt-rss.org/fox/tt-rss.git ${HOME}/tt-rss && env -C ${HOME}/tt-rss git checkout 328d7b55c8
RUN echo > /etc/ssh/sshd_config && \
    wget -qO- https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip | funzip > /usr/bin/ngrok && chmod a+x /usr/bin/ngrok && \
    wget -qO /etc/dnsmasq.conf.ads-yoyo "http://pgl.yoyo.org/as/serverlist.php?hostformat=dnsmasq-server&showintro=0&startdate%5Bday%5D=&startdate%5Bmonth%5D=&startdate%5Byear%5D=&mimetype=plaintext" && \
    # --
    sed -i 's/^\(listen-address.*\)/#\1/' /etc/privoxy/config && \
    ( echo '{+block{Ad Domains from pgl.yoyo.org} +handle-as-empty-document}' && wget -qO- "http://pgl.yoyo.org/as/serverlist.php?hostformat=junkbuster&showintro=0&startdate%5Bday%5D=&startdate%5Bmonth%5D=&startdate%5Byear%5D=&mimetype=plaintext" ) > /etc/privoxy/ads.yoyo.action && \
    curl -sS https://rclone.org/install.sh | bash && \
    mkdir -p /var/squid/cache && chmod 777 /var/squid/cache && squid -Nz && \
    sed -i 's/en_US/en_CA/' /etc/locale.gen && locale-gen

ENV LANG=en_CA.UTF-8
ENV LANGUAGE=$LANG LC_ALL=$LANG

COPY . $HOME
RUN while read -r s d; do cat $HOME/conf/$s >> $d; done < $HOME/conf.csv
RUN chown -R ${NB_UID} ${HOME}

USER ${NB_USER}
